<template>
  <div class="home">
    <p class="postion">当前鼠标位置: {{ x }}, {{ y }}</p>
    <div>随机数: {{ round }}</div>
    <div class="font-bold">{{ count }}</div>
    <el-button class="bg-sky-600" type="primary" @click="add">+1</el-button>
  </div>
</template>

<script setup>
import { useMouse } from '@/utils/common'
const { x, y } = useMouse()
const count = ref(0)
// 随机数
const round = ref(null)
const stop = watchEffect(() => {
  // console.log(' count.value',  count.value)
  round.value = parseInt(Math.random() * 10) + count.value
}, {
  flush: 'post'
})
const add = () => {
  /* if (isRef(count)) { // 检查是不是ref创建的
    count.value++
  } */
  isRef(count) ? count.value++ : count
  if (count.value > 5) {
    stop()
  }
}

</script>

<style lang="scss" scoped>
.home {
  width: 100%;
  height: 100%;
  .postion{
    position: absolute;
    left: 0;
    bottom: 0;
  }
}
</style>
